]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Fix minimum height request, handle 0 allocation better
authorColin Walters <walters@verbum.org>
Thu, 1 Oct 2009 13:18:05 +0000 (09:18 -0400)
committerColin Walters <walters@verbum.org>
Fri, 23 Oct 2009 02:08:56 +0000 (22:08 -0400)
First, fix a problem where though we intended to request a minimum
height of 0 for the docs content, we were actually requesting
spacing for all items.

On low resolution screens, we were still attempting to allocate
an item even when we were given 0 height.

https://bugzilla.gnome.org/show_bug.cgi?id=596984

js/ui/docDisplay.js

index 87c7bf4aae4e44a4571466dbf10c881b69dc8235..9596b0b4324bee1fc362285ce0977e414a51d164 100644 (file)
@@ -354,16 +354,14 @@ DashDocDisplay.prototype = {
         // Two columns, where we go vertically down first.  So just take
         // the height of half of the children as our preferred height.
 
-        let firstColumnChildren = children.length / 2;
+        let firstColumnChildren = Math.ceil(children.length / 2);
 
-        alloc.min_size = 0;
         for (let i = 0; i < firstColumnChildren; i++) {
             let child = children[i];
             let [minSize, naturalSize] = child.get_preferred_height(forWidth);
             alloc.natural_size += naturalSize;
 
             if (i > 0 && i < children.length - 1) {
-                alloc.min_size += DEFAULT_SPACING;
                 alloc.natural_size += DEFAULT_SPACING;
             }
         }
@@ -384,14 +382,16 @@ DashDocDisplay.prototype = {
         // Loop over the children, going vertically down first.  When we run
         // out of vertical space (our y variable is bigger than box.y2), switch
         // to the second column.
-        for (; i < children.length; i++) {
+        while (i < children.length) {
             let child = children[i];
 
             let [minSize, naturalSize] = child.get_preferred_height(-1);
 
             if (y + naturalSize > box.y2) {
-                // Is this the second column?  Ok, break.
-                if (columnIndex == 1) {
+                // Is this the second column, or we're in
+                // the first column and can't even fit one
+                // item?  In that case, break.
+                if (columnIndex == 1 || i == 0) {
                     break;
                 }
                 // Set x to the halfway point.
@@ -399,6 +399,10 @@ DashDocDisplay.prototype = {
                 x = x + itemWidth + DEFAULT_SPACING;
                 // And y is back to the top.
                 y = box.y1;
+                // Retry this same item, now that we're in the second column.
+                // By looping back to the top here, we re-test the size
+                // again for the second column.
+                continue;
             }
 
             let childBox = new Clutter.ActorBox();
@@ -411,6 +415,8 @@ DashDocDisplay.prototype = {
 
             child.show();
             child.allocate(childBox, flags);
+
+            i++;
         }
 
         // Everything else didn't fit, just hide it.